#include "sqlite.hpp"
#include <cassert>
#include <iostream>
int select_stu_Callback(void *arg, int col_count, char **result, char **fields_name)
{
    std::vector<std::string> *arry = static_cast<std::vector<std::string> *>(arg);
    arry->push_back(result[0]);
    return 0; // 必须有
}
int main()
{

    SqliteHelper helper("./test.db");
    // 1.创建表
    assert(helper.open());
    // 2.创建表（不存在则创建），学生信息：学号，姓名、年龄
    const char *ct = "create table if not exists student(sn int primary key,name varchar(32),age int);";
    assert(helper.exec(ct, nullptr, nullptr));
    // 3.增删查改
    // const char *insert_sql = "insert into student values(1, '小明', 18),(2, '小黑', 19);";
    // assert(helper.exec(insert_sql, nullptr, nullptr));
    // const char*sql="select sn,name,age from student;";
    const char *select_sql = "select name from student;";
    std::vector<std::string> arry;
    assert(helper.exec(select_sql, select_stu_Callback, &arry));
    for (auto &name : arry)
    {
        std::cout << name << std::endl;
    }
    // 4.关闭数据库
    helper.close();
    return 0;
}